package com.watchmen.clickhouse.config;

import javax.annotation.Resource;
import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.druid.pool.DruidDataSource;
/**
 * 
 * @author kk
 * Druid数据库连接池配置
 */
@Configuration
public class DruidConfig {

	@Resource
	private JdbcParamConfig jdbcParamConfig;
	
	@Bean
	public DataSource dataSource() {
		DruidDataSource dataSource = new DruidDataSource();
		dataSource.setUrl(jdbcParamConfig.getUrl());
		dataSource.setDriverClassName(jdbcParamConfig.getDriverClassName());
		dataSource.setInitialSize(jdbcParamConfig.getInitialSize());
		dataSource.setMinIdle(jdbcParamConfig.getMinIdle());
		dataSource.setMaxActive(jdbcParamConfig.getMaxActive());
		dataSource.setMaxWait(jdbcParamConfig.getMaxWait());
		return dataSource;
	}
}
